package com.example.zhangxinying.smratchatnew;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
 * Created by zhangxinying on 16/9/13.
 */
public class RecommendFoodAdapter extends RecyclerView.Adapter<RecommendFoodAdapter.ViewHolder> {
    private List<RecommendFoodBean> mylist=null;
    private Context mContext=null;

    public RecommendFoodAdapter(Context context,List<RecommendFoodBean> mylist){
        this.mContext=context;
        this.mylist=mylist;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ViewHolder viewHolder;
        viewHolder=new ViewHolder(LayoutInflater.from(mContext).inflate
                (R.layout.recycler_item_recommend_food,null,false));
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.text_recycler_item_dp_name.setText(mylist.get(position).getRecommendName());
        holder.text_recycler_item_dp_number.setText(mylist.get(position).getRecommendNumber());
        holder.text_recycler_item_dp_sum.setText(mylist.get(position).getRecommendSum());
    }

    @Override
    public int getItemCount() {
        int count=(this.mylist==null?0:this.mylist.size());
        return count;
    }


     class ViewHolder extends  RecyclerView.ViewHolder{
          TextView text_recycler_item_dp_name,text_recycler_item_dp_number,text_recycler_item_dp_sum;
        public ViewHolder(View itemView) {
            super(itemView);
            text_recycler_item_dp_name=(TextView)itemView.findViewById(R.id.tv_food_name);
            text_recycler_item_dp_number=(TextView)itemView.findViewById(R.id.tv_food_number);
            text_recycler_item_dp_sum=(TextView)itemView.findViewById(R.id.tv_res_sum);
        }
    }
}
